package com.kim.smartring.utils;

public class ConfigUtils {

	private static final String configPath = "smartring.config";
	private static final String key_userAddressInfo = "uaddr";
	private static final String key_deviceName = "dname";
	private static final String key_alarmTime = "at";
	private static final String key_weekdayIndex = "wi";

	/**
	 * 获取用户位置信息
	 * 
	 * @return
	 */
	public static String getUserAdddressInfo() {
		return SharedPreferencesUtils.getValueInPrivateMode(configPath,
				key_userAddressInfo, "");
	}

	/**
	 * 设置用户位置信息
	 * 
	 * @param userAddressInfo
	 */
	public static void setUserAddressInfo(String userAddressInfo) {
		SharedPreferencesUtils.setValueInPrivateMode(key_userAddressInfo,
				userAddressInfo, configPath);
	}

	/**
	 * 判断用户位置信息是否已设定
	 * 
	 * @return
	 */
	public static boolean isUserAddressInfoAvailable() {
		return StringUtils.isEmpty(getUserAdddressInfo());
	}

	/**
	 * 判断手环设备是否已绑定
	 * 
	 * @return
	 */
	public static boolean isDeviceBinded() {
		return !StringUtils.isEmpty(getBindedDeviceName());
	}

	/**
	 * 获取已绑定手环名称
	 * 
	 * @return
	 */
	public static String getBindedDeviceName() {
		return SharedPreferencesUtils.getValueInPrivateMode(configPath,
				key_deviceName, "");
	}

	/**
	 * 设置绑定设备名称
	 * 
	 * @param deviceName
	 */
	public static void setBindedDeivceName(String deviceName) {
		SharedPreferencesUtils.setValueInPrivateMode(key_deviceName,
				deviceName, configPath);
	}

	/**
	 * 获取绑定设备物理地址
	 * 
	 * @param deviceName
	 * @return
	 */
	public static String getBindedDeviceAddress(String deviceName) {
		return SharedPreferencesUtils.getValueInPrivateMode(configPath,
				deviceName, "");
	}

	/**
	 * 根据设备名称保存对应设备物理地址
	 * 
	 * @param deviceName
	 * @param deviceAddress
	 */
	public static void setBindedDeviceAddress(String deviceName,
			String deviceAddress) {
		SharedPreferencesUtils.setValueInPrivateMode(deviceName, deviceAddress,
				configPath);
	}

	/**
	 * 设置闹钟时间
	 * 
	 * @param alarmTime
	 */
	public static void setAlarmTime(long alarmTime) {
		SharedPreferencesUtils.setValueInPrivateMode(key_alarmTime, alarmTime,
				configPath);
	}

	/**
	 * 获取闹钟时间
	 * 
	 * @return
	 */
	public static long getAlarmTime() {
		return SharedPreferencesUtils.getValueInPrivateMode(configPath,
				key_alarmTime, 0l);
	}

	/**
	 * 保存闹钟重复星期
	 * 
	 * @param weekdayIndex
	 */
	public static void setWeekdayIndex(int weekdayIndex) {
		SharedPreferencesUtils.setValueInPrivateMode(key_weekdayIndex,
				weekdayIndex, configPath);
	}

	/**
	 * 获取闹钟重复星期
	 * 
	 * @return
	 */
	public static int getWeekdayIndex() {
		return SharedPreferencesUtils.getValueInPrivateMode(configPath,
				key_weekdayIndex, 0);
	}

}
